package com.ctsi.security.service;

import com.ctsi.commons.util.UtilValidate;
import com.ctsi.framework.mybatis.support.MybatisGenericDao;
import com.ctsi.security.domain.SRoleUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class SecRelateRoleService {

    @Autowired
    private MybatisGenericDao dao;

    /**
     * 根据用户userLoginId获取用户权限相关的角色 需要排序
     *
     * @param userLoginId 用户userLoginId
     * @return
     */

    public List<String> getRoleByLoginId(String userLoginId) {
        if (UtilValidate.isEmpty(userLoginId))
            throw new RuntimeException("userLoginId is not valid");
        return (List<String>) dao.queryForList(SRoleUser.class.getName() + ".queryRoleByUserId", userLoginId);

    }


}
